package com.kevin.memo;

/**
 * 代理模式测试类
 *
 * @author kevin
 * @date 2025/8/7
 */
public class ProxyTest {

    public static void main(String[] args) {
        // 静态代理
        Subject subject = new Proxy();
        subject.request();

        // JDK 动态代理
        RealSubject realSubject = new RealSubject();
        DynamicProxyHandler handler = new DynamicProxyHandler(realSubject);
        Subject proxy = (Subject) handler.getProxy();
        proxy.request();

        // CGLIB 动态代理
        CglibProxy cglibProxy = new CglibProxy();
        RealSubject cglibSubject = (RealSubject) cglibProxy.getProxyInstance(new RealSubject());
        cglibSubject.request();
    }
}
